package com.ethanJun.csdn.config;

import com.ethanJun.csdn.domain.service.CsdnArticleToolComponent;
import com.ethanJun.csdn.infrastructure.ICSDNInterface;
import com.ethanJun.csdn.infrastructure.ICSDNService;
import org.springframework.ai.tool.ToolCallbackProvider;
import org.springframework.ai.tool.method.MethodToolCallbackProvider;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import retrofit2.Retrofit;
import retrofit2.converter.jackson.JacksonConverterFactory;

/**
 * @author 衣立君
 * @date 2025/04/24 21:17
 **/
@Configuration
public class CSDNConfig {

    @Bean
    public ToolCallbackProvider csdnTools(CsdnArticleToolComponent csdnArticleToolComponent) {
        return MethodToolCallbackProvider.builder().toolObjects(csdnArticleToolComponent).build();
    }


    @Bean
    public ICSDNInterface csdnInterface() {
        Retrofit retrofit = new Retrofit.Builder()
                .baseUrl("https://bizapi.csdn.net/")
                .addConverterFactory(JacksonConverterFactory.create())
                .build();
        return retrofit.create(ICSDNInterface.class);
    }

}